function Clock() {
}

Clock.init = function () {
    Log.logWithFacility( "CLOCK", "Instantiating Clock" );
    Clock.tick();
    Clock.interval = setInterval("Clock.tick()",1000);
};

Clock.tick = function() {
    var date = new Date();
    if( null == Clock.element ) {
	Clock.element = document.getElementById("clock");
    }
    if( null != Clock.element ) {
        Clock.element.innerHTML = ""
            + Clock.justify( date.getHours() ) + ":"
            + Clock.justify( date.getMinutes() ) + ":"
    	    + Clock.justify( date.getSeconds() )
            ;
    }
};

Clock.justify = function( st ) {
    var rv;
    
    if( st < 10 ) {
        rv = "0" + st;
    } else {
        rv = "" + st;
    }

    return( rv );
};

Clock.init();
